<?php
class Admin_Form_Admin extends Zend_Form
{

    public function init()
    {
        $this->setName("admin");

        $userId = new Zend_Form_Element_Hidden('adminId');
        $userId->addFilter('Int');
        
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel('Tên tài khoản')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $username->setAttrib('size', 60);
        
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Mật khẩu')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $password->setAttrib('size', 60);

        $userRole = new Zend_Form_Element_Multiselect('userRole');
        $userRole->setLabel('Quyền hạn')->setRequired(true);
        $model_roles = new Admin_Model_Role();
        $roles_list = $model_roles->getAllData();
        foreach ($roles_list as $role) {
            $userRole->addMultiOption($role['roleId'],$role['roleName']);
        }
        
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('EmailAddress');
        $email->setAttrib('size', 60);
                
        $status = new Zend_Form_Element_Select('status');
        $status->setLabel('Trạng thái');
        $status->addMultiOption('1','Đang hoạt động');
        $status->addMultiOption('0','Tạm khóa');

        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");
                
        // add elements to form
        $this->addElements(array (
            $userId, $username, $password, $birthday, $email, $userRole, $status, $submit
        ));
    }
}

